//地点获取
var allDistrictCities = ["齐齐哈尔|44","鹤岗|46","大庆|48","佳木斯|50","牡丹江|52","绥化|54","南京|56",
                         "徐州|58","苏州|60","连云港|62","盐城|64","泰州|67","宁波|70","温州|71",
                         "绍兴|74","台州|78","合肥|80","蚌埠|82","淮北|85","黄山市|88","秦皇岛|91",
                         "保定|94","沧州|97","廊坊|98","大同|101","晋城|104","晋中|106","临汾|109",
                         "包头|112","赤峰|114","呼伦贝尔|117","阿拉善盟|122","鞍山|125","丹东|128",
                         "阜新|131","盘锦|133","葫芦岛|136","四平|139","辽源|140","松原|143",
                         "滁州|146","宿州|148","六安|150","宣城|153","厦门|155","泉州|158","龙岩|161",
                         "景德镇|164","九江|166","鹰潭|168","吉安|170","抚州|172","济南|174","淄博|176",
                         "东营|178","烟台|179","济宁|181","莱芜|185","德州|187","滨州|189","郑州|191",
                         "洛阳|193","肇庆|195","梅州|197","河源|199","清远|201","中山|203","揭阳|205",
                         "云浮|206","桂林|209","北海|211","钦州|213","玉林|215","河池|218","崇左|220",
                         "凉山|223","贵阳|224","遵义|226","铜仁|228","毕节|230","黔东南|231","昆明|233",
                         "玉溪|235","保山|236","普洱|239","文山|243","大理|245","怒江|247","拉萨|249",
                         "山南|251","那曲|253","西安|256","三亚|257","攀枝花|260","广元|264","乐山|267",
                         "眉山|269","达州|272","资阳|275","鹤壁|278","焦作|280","许昌|282","漯河|283",
                         "商丘|286","周口|288","武汉|291","宜昌|294","鄂州|296","孝感|298","咸宁|301",
                         "仙桃|304","天门|306","株洲|309","邵阳|312","张家界|315","永州|318","娄底|320",
                         "韶关|323","珠海|325","佛山|327","湛江|329","铜川|331","咸阳|333","延安|335",
                         "榆林|337","商洛|339","嘉峪关|341","白银|343","武威|345","张掖|346","酒泉|348",
                         "定西|350","临夏|352","西宁|354","海东地区|355","黄南藏族|357","果洛藏族|359",
                         "海西藏族|361","石嘴山|363","固原|365","克拉玛依|368","哈密|370","博尔塔拉|372",
                         "阿克苏|374","喀什地区|376","和田地区|377","塔城地区|379","石河子|381","图木舒克|383",
                         "绵阳|263","哈尔滨|43","鸡西|45","双鸭山|47","伊春|49","七台河|51","黑河|53","大兴安岭|55",
                         "无锡|57","常州|59","南通|61","淮安|63","镇江|66","杭州|69","湖州|73","金华|75","舟山|77",
                         "芜湖|81","马鞍山|84","铜陵|86","邯郸|92","张家口|95","衡水|99","阳泉|102","朔州|105",
                         "忻州|108","吕梁|110","乌海|113","鄂尔多斯|116","巴彦淖尔|118","锡林郭勒盟|121","大连|124",
                         "抚顺|126","锦州|129","辽阳|132","朝阳市|135","长春|137","白山|142","白城|144","阜阳|147",
                         "巢湖|149","亳州|151","福州|154","三明|157","南平|160","宁德|162","萍乡|165","新余|167",
                         "赣州|169","宜春|171","上饶|173","青岛|175","枣庄|177","潍坊|180","泰安|182","日照|184",
                         "临沂|186","聊城|188","菏泽|190","开封|192","平顶山|194","惠州|196","汕尾|198","阳江|200",
                         "东莞|202","潮州|204","南宁|207","柳州|208","梧州|210","防城港|212","贵港|214","百色|216",
                         "贺州|217","来宾|219","海口|221","甘孜|222","六盘水|225","安顺|227","黔西南|229","黔南|232",
                         "昭通|237","临沧|240","红河|242","德宏|246","昌都|250","日喀则|252","林芝|255","自贡|259",
                         "泸州|261","遂宁|265","南充|268","广安|271","雅安|273","安阳|277","新乡|279","濮阳|281",
                         "三门峡|284","信阳|287","济源|290","黄石|292","襄阳|295","荆州|299","随州|302","潜江|305",
                         "神农架|307","衡阳|311","岳阳|313","益阳|316","怀化|319","广州|322","深圳|324","汕头|326",
                         "江门|328","茂名|330","宝鸡|332","渭南|334","汉中|336","安康|338","兰州|340","金昌|342",
                         "天水|344","扬州|65","宿迁|68","嘉兴|72","衢州|76","丽水|79","淮南|83","安庆|87","唐山|90",
                         "邢台|93","承德|96","太原|100","长治|103","运城|107","呼和浩特|111","通辽|115",
                         "乌兰察布|119","沈阳|123","本溪|127","营口|130","铁岭|134","通化|141","池州|152",
                         "莆田|156","漳州|159","曲靖|234","楚雄|241","迪庆|248","阿里|254","成都|258","内江|266",
                         "巴中|274","南阳|285","驻马店|289","十堰|293","黄冈|300","湘潭|310","常德|314","郴州|317",
                         "平凉|347","庆阳|349","陇南|351","甘南|353","海北藏族|356","海南藏族|358","玉树|360",
                         "银川|362","吴忠|364","中卫|366","乌鲁木齐|367","吐鲁番|369","昌吉回族|371","巴音郭楞|373",
                         "克孜勒苏|375","伊犁|378","阿勒泰|380","阿拉尔|382","五家渠|384","吉林市|138","延边|145",
                         "南昌|163","丽江|238","西双版纳|244","德阳|262","宜宾|270","阿坝|276","荆门|297","湘西|321",
                         "北京|13","重庆|31","上海|9","天津|14","石家庄|89","兴安盟|120","威海|183","长沙|308","中国澳门|41","中国香港|40"];
var idValue ="";
var domain = "s";
$("li[name='ticketrec_group']").each(function(i,n){
	var id=$(n).attr("id");
	var ValueJ = $("#"+id+"_div");
	idValue = idValue + ValueJ.attr("value") + ",";//目的地id
	var type2 = ValueJ.attr("type");
	domain=type2=="seo"?"ticket":"s";
});
if(idValue!=""){
	var urlStr="http://"+domain+".lvmama.com/vstRoute/ticket_group_filter.do?destId="+encodeURI(encodeURI(idValue));
	$.ajax({
		url :urlStr,
		dataType : "text",
		success : function(data) {
			var reslut = data;
			if (reslut != ""||reslut != null) {
				reslut=reslut.substring(0,reslut.length-1);
				var strs= new Array();
				strs=reslut.split(",");
				for (i=0;i<strs.length ;i++ ) {
					$(".ticket_group_"+strs[i]).show();
				}
			}else{
			}
		},
		error : function() {
		}
	});
}

// 跟团游选项卡增加 click() 事件
$("li[name='ticketrec_group']").each(function(i,n){
	$(n).click(function(){
		var id=$(this).attr("id");
		var ValueJ = $("#"+id+"_div");
		if(ValueJ.text()==null||ValueJ.text()==""||ValueJ.text().indexOf("目前没有相关的")>=0){
			var idValue = ValueJ.attr("value"); // 目的地id
			var idName =  ValueJ.attr("name");  // 目的地名称
			var type2 = ValueJ.attr("type");
			var domain=type2=="seo"?"ticket":"s";
            var urlStr;
            if (id.indexOf("route") >= 0) {
                urlStr = "http://" + domain + ".lvmama.com/vstRoute/ticket_route.do?destId=" + encodeURI(encodeURI(idValue)) + "&idName=" + encodeURI(encodeURI(idName));
            } else if (id.indexOf("group") >= 0) {
                urlStr = "http://" + domain + ".lvmama.com/vstRoute/ticket_group.do?destId=" + encodeURI(encodeURI(idValue)) + "&idName=" + encodeURI(encodeURI(idName));
            }
			$.ajax({
				url :urlStr,
				dataType : "html",
				success : function(data) {
					if (data != "") {
						ValueJ.html(data);
					}else{
					}
				},
				error : function() {
				}
			});
		}
	});
});

/**
 * 景酒自由行选项卡增加 click() 事件，点击选项卡后：
 * 1. 将门票产品的目的地 ID 和该目的地配置的景酒自由行广告位产品 ID 传入 ticket_route.do
 * 2. 返回显示该门票产品所在目的地相关的景酒自由行产品
 */
$("li[name='ticketrec_route']").each(function (index, element) {
    $(element).click(function () {
        var tabId = $(this).attr("id"); // 选项卡的 ID
		var listId = tabId + "_div";    // 选项卡对应的列表元素的 ID
        var listObject = $("#" + listId);   // 列表元素的 JQuery 对象
        if (listObject.text() == null || listObject.text() == "" || listObject.text().indexOf("目前没有相关的") >= 0) {
            var destinationId = listObject.attr("value");                    // 门票产品的目的地 ID
            var destinationName = listObject.attr("name");                   // 门票产品的目的地名，用于“更多”按钮跳转使用
            var destinationAdProductsIdScenicTour = listObject.attr("attribute1"); // 该目的地配置的景酒自由行广告位产品 ID
            var type = listObject.attr("type");
            var domain = type == "seo" ? "ticket" : "s";
            var urlString = "http://" + domain + ".lvmama.com/vstRoute/ticket_route.do"
					+ "?destId=" + encodeURI(destinationId)
                    + "&idName=" + encodeURI(destinationName)
					+ "&destinationAdProductsIdScenicTour=" + encodeURI(destinationAdProductsIdScenicTour);
            $.ajax({
                url: urlString,
                dataType: "html",
                success: function (data) {
                    if (data != "") {
                        listObject.html(data);
                    } else {
                    }
                }
            });
        }
    });
});

$("li[name='no_ticket_route'],li[name='no_ticket_group']").each(function(i,n){
	$(n).click(function(){
		var id=$(this).attr("id");
		var ValueJ = $("#"+id+"_div");
		if(ValueJ.text()==null||ValueJ.text()==""||ValueJ.text().indexOf("目前没有相关的")>=0){
			var idValue = ValueJ.attr("value");//目的地id
			var idName =  ValueJ.attr("name");//目的地名称 
			var type2 = ValueJ.attr("type");
			var domain=type2=="seo"?"ticket":"s";
			if(id.indexOf("route")>=0){
				var urlStr="http://"+domain+".lvmama.com/vstRoute/ticket_route.do?destId="+encodeURI(encodeURI(idValue))+"&idName="+encodeURI(encodeURI(idName));
			}
			else if (id.indexOf("group")>=0){
				var urlStr="http://"+domain+".lvmama.com/vstRoute/ticket_group.do?destId="+encodeURI(encodeURI(idValue))+"&idName="+encodeURI(encodeURI(idName));
			}
			$.ajax({
				url :urlStr,
				dataType : "html",
				success : function(data) {  
					if (data != "") {
						ValueJ.html(data);
					}else{
					}  
				},
				error : function() {
				}
			});
		}
	}); 
});


function submitForm() {
	var searchForm = $("#searchForm");
	// alert("searchForm: "+searchForm.html());
	searchForm.submit();
	// var searchForm=$("#keyword");
}

function setKeywords(o) {
	var keyword = $("#keyword");
	keyword.val(o.innerHTML);
	submitForm();
}

$(function(){
		$(".product-special-items-main").bind("click",
			function() {
				var $dl = $(this).parents(".product-special-list");
				var hide_box = $dl.find('.psi-tab-contents');
				var content = $.trim(hide_box.html());
				if(content=="" || content.length==0){
					var id = hide_box.attr("pdetailsId");
					var aperiodicFlag = hide_box.attr("aperiodicFlag");
					hide_box.html("<div class='psi-tab-content active'></div>");
					$.ajax({
						type : "POST",
						url : "http://s.lvmama.com/vstTicket/showGoodsDesc.do?id="+ id + "&flag="+aperiodicFlag+"&tt=" + Math.random(),
						dataType : "JSONP",
						jsonp:"callback",
						success : function(data) {
							if(data) {
								//alert(data[0]+"----"+data[1]+"----"+data[2]);
								var index = 1;
								var html = '<div class="psi-tab-content active">';
								html  += ' <dl class="clearfix"><dt>费用包含</dt><dd>'+data[0].priceIncludes+'</dd></dl>';
								if(data[0].costsNotIncluded){
									html  += ' <dl class="clearfix"><dt>费用不包含</dt><dd>'+data[0].costsNotIncluded+'</dd></dl>';
								}
								if(data[3]){
									html  += ' <dl class="clearfix"><dt>预定时间</dt><dd>游玩'+data[3]+'前可下单，请尽早预订，以免耽误您的行程。</dd></dl>';
								}
								if (data[0].visitAddress && data[0].typeDesc) {
									html  += ' <dl class="clearfix"><dt>票种说明</dt><dd>'+data[0].typeDesc+'</dd></dl>';
								}
								html  += '<dl class="clearfix"><dt>入园须知</dt><dd>';
								if (data[0].visitAddress) {
									html  +=   index + '.入园时间：'+ data[0].limitTime;
									if(data[0].passLimitTimeStr){
										html  += '(预定成功后' + data[0].passLimitTimeStr + '可入园)'
									}
									html +=  '<br>';
									index++;
									html  +=   index + '.入园地点：'+ data[0].visitAddress + '<br>';
									index++;
								}
								if(data[0].changeTime) {
									html  +=   index + '.取票时间：'+ data[0].changeTime + '<br>';
									index++;
								}
								
								if(data[0].changeAddress) {
									html  +=   index+'.取票地点：'+ data[0].changeAddress +'<br>';
									index++;
								}
								
								if(data[0].enterStyle) {
									html  +=   index + '.入园方式：'+ data[0].enterStyle +'<br>';
									index++;
								}
								
								if(data[0].limitTime && data[0].visitAddress == "") {
									html  += index+'.入园限制:' + (data[0].limitFlag=='1'?'无限制<br>':'有限制 请在入园当天的 '+ data[0].limitTime +' 以前入园<br>') ; 
									index++;
								}
								
								//拼接有效期限
								if(data[1].startTime || data[1].endTime || data[1].unvalidDesc || data[1].useInsTruction || data[1].days) {
									html  +=   index+'.有效期限：';
									if (data[5]=='Y') {
										html  += data[4]; 
										index++;
									} else {
										if(data[1].useType){
											if (data[1].useInsTruction) {
												html  +='（'+ data[1].useInsTruction +'）';
											}
											
											if(data[1].useType=='VISIT_TIME'){
												//从游玩之日起
												if(data[1].days == 1) {
													   html  += '指定游玩日当天内有效';  
												} else {
													   html  += '指定游玩日'+ data[1].days + '天内有效';  
												}
											}else if(data[1].useType=='ORDER_TIME'){
												//从下单之日起
												if(data[1].days == 1) {
													   html  += '下单日当天内有效';  
												} else {
													   html  += '从下单日起'+ data[1].days + '天内有效';  
												}
												
											} else if(data[1].useType=='PERIOD_TIME'){
												//固定时间段
												if(data[1].startTimeStr && data[1].endTimeStr){
													html  += data[1].startTimeStr+"~"+data[1].endTimeStr; 
												}
											}
											index++;
										}
									}
									html += '<br>';
									
								}
								
								if(data[6]){
									html += index + '.限购政策：' + data[6];
									index++;
								}
								
								
								html  += '</dd></dl>';
								if(data[0].height || data[0].age || data[0].region || data[0].maxQuantity || data[0].express || data[0].entityTicket || data[0].others) {
									html  += '<dl class="clearfix"><dt>重要提示</dt><dd>';
									if(!data[0].height && !data[0].age && !data[0].region && !data[0].maxQuantity && !data[0].express && !data[0].entityTicket) {
										html  += data[0].others;
								    } else {
								    	html  += '票种说明:' +'<br>';
								    	html  += '身高: ' + data[0].height +'<br>';
										html  += '年龄: ' + data[0].age +'<br>';
										html  += '地域: ' + data[0].region +'<br>';
										html  += '最大限购: ' + data[0].maxQuantity +'<br>';
										html  += '快递: ' + data[0].express +'<br>';
										html  += '实体票: ' + data[0].entityTicket +'<br>';
										html  += '其它: ' + data[0].others +'<br>';
								    }
									html  += '</dd></dl>';
								}
								if(data[2]) {
									html  +='<dl class="clearfix">';
									html  +='<dt>退改说明</dt>';
									html  +='<dd>';
									html += data[2];
									html  += '</dd>';
									html  += '</dl>';
								}
								
								html  +=  '</div>';
								hide_box.html(html);
							}
						}
					});
				}
				
			});
		
		
	
	if ($("#guide_data_div").length > 0) 
	{
	// alert("攻略");
	var placeId = $("#guide_data_div").attr("placeId");
	var official_Guide = true;
	$.ajax({
				url : "http://www.lvmama.com/guide/ajax/api.php?action=getOrgInfo&id="+placeId,
				dataType : "jsonp",
				success : function(res) {
					var data = res.data;
					// alert("data3: "+data);
					if (data != null && data != "") {
						var g1="<h4 class='common_tit2'>"+data.name+"旅游攻略</h4>"; 
						g1 = g1+'<div class="gonglve">';
						g1 = g1+'<dl class="official_guide clearfix">';
						g1 = g1+ '<dt><a target="_blank" href="'+data.url+'"><img width="90" height="127" alt="" src="'
								+ data.thumb + '"></a></dt>';
						g1 = g1 + '<dd>';
						g1 = g1 + '<p class="version">攻略版本：<br>' + data.version
								+ '</p>';
						g1 = g1 + '<p class="update_time">更新时间：<span>'
								+ data.updatetime + '</span></p>';
						g1 = g1 + '<a   target="_blank" hidefocus="false" href="' + data.url
								+ '" class="btn btn-small btn-orange">下载攻略</a>';
						g1 = g1 + '</dd>';
						g1 = g1 + '</dl>';
						g1 = g1 + '<ul id="guide_data_list" class="guide_list">';
						g1 = g1 + '<div class="download_loading"></div>';
						g1 = g1 + '</ul>';
						g1 = g1 + '</div>';
						//alert("g1: "+g1);
						$("#guide_data_div").html(g1);
						
						$.ajax({
							url : "http://www.lvmama.com/guide/ajax/api.php?action=getOrgLatestArticle&id="+placeId,
							dataType : "jsonp",
							success : function(res2) {
								//alert("res2.data3: "+res2.data);
								if (res2.data != null && res2.data != "") {
									var g2 = "";
									$.each(res2.data, function(i, n) {
										g2 = g2 + '<li>';
										g2 = g2 + '<a target="_blank" href="' + n.url + '">'
												+ n.title + '</a>';
										g2 = g2 + '<p class="scan_detail">';
										g2 = g2 + '<span>' + n.inputtime
												+ '</span>';
										g2 = g2 + '<i>浏览' + n.hits + '次</i>';
										g2 = g2 + '</p>';
										g2 = g2 + '</li>';
									});
									$("#guide_data_list").html(g2);
								} else if (!official_Guide) {
									$("#guide_data_div").hide();
								}
							},
							error : function(XMLHttpRequest, textStatus, errorThrown) {
								if (!official_Guide) {
									$("#guide_data_div").hide();
								}
							}
						});
						
						
					} else {
						official_Guide = false;
						$("#guide_data_div").hide();
					}
				},
				error : function() {
					$("#guide_data_div").hide();
				}
			});
	}
	
	if ($("#ticket_seo_gonglve").length > 0) {
	// alert("攻略");
	var placeId = $("#ticket_seo_gonglve").attr("placeId");
	var official_Guide = true;
	$.ajax({
		// url:
		// "http://ticket.lvmama.com/search/js/shgl1.json",
		// "http://www.lvmama.com/guide/ajax/api.php?action=getOrgInfo&id="+placeId+"?jsoncallback=?",
		url : "http://www.lvmama.com/guide/ajax/api.php?action=getOrgInfo&id="+placeId,
		dataType : "jsonp",
		success : function(res) {
			var data = res.data;
			// alert("data3: "+data);
			if (data != null && data != "") {
				var g1='<dt><a href="#"><img width="90" height="127" alt="" src="'+data.thumb+'"></a></dt>'; 
				g1 = g1 + '<dd>';
				g1 = g1 + '<p class="version">攻略版本：<br>'+data.version+'</p>';
				g1 = g1 + '<p class="update_time">更新时间：<span>'+data.updatetime+'</span></p>';
				g1 = g1 + '<a target="_blank" hidefocus="false" href="'+data.url+'" class="btn btn-small btn-orange">下载攻略</a>';
				g1 = g1 + '</dd>';
				g1 = g1 + '</dl>';
				//alert("g1: "+g1);
				$("#ticket_seo_gonglve").html(g1);
			} else {
				official_Guide = false;
			}
		},
		error : function() {
			$("#ticket_seo_gonglve").hide();
		}
	});}
	
	
	if ($("#cmt_data_div").length > 0) {
		var placeId = $("#cmt_data_div").attr("placeId");
		$.ajax({
			url : "http://s.lvmama.com/ajax/cmt.do?placeId=" + placeId + "&type=1",
			dataType : "jsonp",
			jsonp : "callback",
			success : function(data) {
				if (data.cmtData != "") {
					$("#score_detail").html(data.cmtData);
				} else {
					$("#score_detail").parent().remove();
				}
			},
			error : function() {
				$("#score_detail").parent().remove();
			}
		});
	};
	
//	(function(){
//		var productIds = $(".product-info").map(function(){
//			return $(this).prop("id");
//		}).get().join(',');
//		$.ajax({
//			url : "http://s.lvmama.com/ajax/showLineProduct.do?productIds=" + productIds+"&type=1",
//			dataType : "jsonp",
//			beforeSend:function(XHR)
//			{
//				if(!productIds)
//				{
//					return false;
//				}
//			},
//			success : function(data) 
//			{
//				if(data)
//				{
//					$.each(data,function(productId,product){
//						var productStr = product.unit
//						if(productStr.indexOf("<br>")>0 ){
//							var str_before = productStr.split("<br>")[0];
//							var str_after = productStr.split("<br>")[1];
//							$("#p"+productId).html(str_before);
//							$("#m"+productId).html(str_after);
//						}else{
//							var mProductId=$("#m"+productId);
//							$("#p"+productId).html(productStr);
//							//mProductId.parentNode.removeChild(mProductId);
//							mProductId.remove();
//						}
//					})
////					$.each(data,function(productId,product){
////						//alert("unit:"+unit);
////						$("#p"+productId).html(product.unit);
////					//	$("label[name=nowLable]","#"+productId).html(unit);
////					})
//				}
//			},
//			error : function() {
//			}
//		});
//	})();
  }
)


function setAdultChild(productId,baseAdultQuantity,baseChildQuantity)
{
	var html = baseAdultQuantity + "成人" + baseChildQuantity + "个儿童";
	if(html=="" || html==null){
		var el=$("#m"+productId);
		el.parentNode.removeChild(el);
	}else{
		$("#m"+productId).html(html);
	}
}

if ($(".product-info").length > 0) {}

// 将分钟数转换为天/时/分
function minutesToDate(time) {
	var time = parseInt(time);
	var day = 0;
	var hour = 0;
	var minute = 0;
	if (time > 0) {
		day = Math.ceil(time / 1440);
		if (time % 1440 == 0) {
			hour = 0;
			minute = 0;
		} else {
			hour = parseInt((1440 - time % 1440) / 60);
			minute = parseInt((1440 - time % 1440) % 60);
		}

	} else if (time < 0) {
		time = -time;
		hour = parseInt(time / 60);
		minute = parseInt(time % 60);
	}
	if (hour < 10)
		hour = "0" + hour;
	if (minute < 10)
		minute = "0" + minute;
	//var str=day + "天" + hour + "点" + minute + "分";
//	alert("str: "+str);
	var str=hour + ":" + minute
	return str;
}


var todayTickets=$(".tagsback-time_data");
$.each(todayTickets,function(n,value) {  
    //do something here 
	var valueJ=$(value);
	var timeValue=valueJ.attr("value");
	var flag=valueJ.attr("flag");
    if(flag=="1")
    {
    	if(timeValue!=null&&timeValue!=''&&timeValue!='0')
		{
    		valueJ.attr("tip-content",minutesToDate(timeValue)+"前可购买当日票")
    		valueJ.find("b").html(minutesToDate(timeValue));
		}
    	else
    	{
    	}
    }	
});  


/*$(".time").countdown({
	format : "dd:hh:mm:ss", // 时间格式 自定义倒计时类型 现支持 dd:hh:mm:ss(默认) hh:mm:ss dd:hh:mm mm:ss 四种格式 
	prezero : true, // 前导零 
	effect : true, // 支持自定义格式  
	overtips : "已结束" // 自定义结束提醒 
	}); */

//加载门票
function getTicketYoulun(id,urlStr)
{
	//alert("keyword: "+keyword+" , len: "+$("#routeTicketContainer").length);
	//alert("urlStr: "+urlStr);
	if ($("#"+id).length > 0) {
		$.ajax({
			url :urlStr,
			dataType : "html",
			success : function(data) {
				// alert("data: "+data);
				// alert("html: "+$("#score_detail").html());
				if (data != "") {
					$("#"+id).html(data);
				}  
				else
				{
					$("#"+id).hide();
				}
			},
			error : function() 
			{
				//$("#ticketContainer").parent().remove();
				$("#"+id).hide();
			}
		});
	}
}



//配置默认选中的出发地
$(function()
{
	var path = window.location.pathname.split("/");
	if(path && path.length > 2)
	{
		var searchString = path[2];
		var destLetterIndex = searchString.indexOf("H") ;
		if(destLetterIndex > -1)//判断是否包含H,H代表出发地
		{
			var nextLetter = searchString.slice(destLetterIndex+1).match(/\D/);//获取下一个字母
			var nextLetterIndex =  nextLetter?searchString.indexOf(nextLetter):0;//获取下一个字母的位置
			var destId  = nextLetterIndex?searchString.slice(destLetterIndex+1, nextLetterIndex):searchString.slice(destLetterIndex+1);//截取H到下一个字母之间的数字
			if(destId == 8)//如果是8  就是全国
			{
				$("b",".btn_city.js_searchbox").attr("data-id",8).text("全国");
				return;
			}
			else if(destId)//如果destId不存在就不做任何处理
			{
	            //var districtCityId = "";
	            for(var i=0; i<allDistrictCities.length;i++){
	                var districtCityInfo = allDistrictCities[i];
	                var districtCityInfos = districtCityInfo.split("|");
	                if(destId == districtCityInfos[1]){
	                	var districtCityName = districtCityInfos[0];
	                	if(districtCityName)//如果通过destId找不到数据.不做任何处理
	    				{
	                		$("b",".btn_city.js_searchbox").attr("data-id",destId).text(districtCityName);
	    				}
	                }
	            }
			}
		}
 	}
});

/**
 * 初始化线路猜你喜欢html
 * @param data
 */
function initGuessYouLikeRoute(data,typeTemp)
{
	var suffix='ICT=i';
	var html = '';
	var type = 'losc=' + typeTemp;
	$(data).each(function(index,item)
	{
		var url = item.url.indexOf("?")>0?item.url+"&"+type+"&"+suffix:item.url+"?"+type+"&"+suffix;
		if(index >= 5)
		{
			return false;
		}
		html +='<a  target="_blank" class="like-link" href="'+url+'">';
		html +='<img src="'+item.simg+'" width="198" height="132" alt="">';
		html+='<h4>'+item.name+'</h4>';
		html+='<div class="price"><em>¥'+item.price+'</em>起</div>';
		html +='</a>';
	})
	if(html)//如果html有循环拼接
	{
		$("#guessYouLikeRoute").html(html);
		$("#guessYouLikeDiv").show();
	}
	else//否则移除当前节点的父节点
	{
		$("#guessYouLikeDiv").remove();
	}
}

/**
 * 初始化门票猜你喜欢html
 * @param data
 */
function initGuessYouLike(data,typeTemp)
{
	var suffix='ICT=i';
	var html = '';
	var type = 'losc=' + typeTemp;
	$(data).each(function(index,item)
	{
		var url = item.url.indexOf("?")>0?item.url+"&"+type+"&"+suffix:item.url+"?"+type+"&"+suffix;
		if(index >= 5)
		{
			return false;
		}
		html +='<li><a  target="_blank" class="sale_img" href="'+url+'" hidefocus="false">';
		html +='<img src="'+item.simg+'" width="198" height="132" alt="">';
		html +='</a>';
		html +='<a target="_blank" class="sale_tit" style="max-height:40px; overflow:hidden;text-overflow:ellipsis;" href="'+url+'" hidefocus="false">'+item.name+'</a>';
		html +='<div class="jiage_box">';
		html +='<a target="_blank" class="btn btn-orange btn-small " href="'+ url +'" hidefocus="false">查看详情</a>';
		html +='<span class="current_price">¥'+item.price+'<i>起</i></span>';
		html +='</div>';
		html +='</li>';
	})
	if(html)//如果html有循环拼接
	{
		$("#guessYouLike").html(html);
		$("#guessYouLikeDiv").show();
	}
	else//否则移除当前节点的父节点
	{
		$("#guessYouLikeDiv").remove();
	}
}

function vstCreateProductviewTag(id,name,category,fromPage)
{
	cmCreateProductviewTag(id,name,category,"-_-"+fromPage+"景点门票");
}


